package com.sjm.bookshop.service.userservice;

import com.sjm.bookshop.dao.AdminDao;
import com.sjm.bookshop.entity.Admin;
import com.sjm.bookshop.utils.MD5Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class AdminService {
    @Autowired
    private AdminDao adminDao;

    //查询管理员列表
    public List<Admin> AdminList() {
        return adminDao.getAdminList();
    }

    //    模糊查询
    public List<Admin> selectSomeOne(String keyWord) {
        return adminDao.getSomeList(keyWord);
    }

    //    修改状态
    public int changeAdminStatus(int adminId, int adminstatus) {
        return adminDao.changeStatus(adminId, adminstatus);
    }

    //    删除普通用户
    public int deleteOne(int adminId) {
        return adminDao.deleteAdmin(adminId);
    }

    //    修改管理信息
    public int UpdateAdminInfo(Admin admin) {
        admin.setPassword(MD5Util.MD5(admin.getPassword()));
        return adminDao.updateInfo(admin);
    }
}
